import dressUpTabbardata from '../../../common/dressUpIndexData.js'
import {hairStyleData,makeUpData} from '../../../common/dressUpData.js'
import { jsCallJavaAbility } from '../../../common/JsCallJavaAbilityUtils.js';
export default {
    data() {
        return {
            dressUpTabbardata:dressUpTabbardata,
            hairStyleData:hairStyleData,
            makeUpData:makeUpData,
            n_color:'#F0F0F0',
            c_color:'#E64C44',
            text: "",
            iskey:0,
            front_id:0,
        }
    },
    onInit() {
    },
    changeTabIndex(e) {
        for (let i = 0; i < this.dressUpTabbardata.length; i++) {
            let element = this.dressUpTabbardata[i];
            element.show = false;
            if (i === e.index) {
                element.show = true;
            }
        }
    },
    take_picture(){
        let camera=this.$element("camera");
        camera.takePhoto('high');
    },
//    点击选择哪个发型
    itemClick(id){

        if(this.front_id!=id){
            this.hairStyleData[this.front_id].isClick=false;
            this.hairStyleData[this.front_id].choose_color=this.n_color;
        }

            this.hairStyleData[id].isClick=!this.hairStyleData[id].isClick;
            this.front_id=id;
            if(this.hairStyleData[id].isClick){
                this.hairStyleData[id].choose_color=this.c_color;
            }
            else{
                this.hairStyleData[id].choose_color=this.n_color;
            }


    },
    //    点击选择哪个妆容
    MitemClick(id){
        if(this.front_id!=id) {
            this.makeUpData[this.front_id].isClick = false;
            this.makeUpData[this.front_id].choose_color = this.n_color;
        }

        this.makeUpData[id].isClick=!this.makeUpData[id].isClick;
        this.front_id=id;
        if(this.makeUpData[id].isClick){
            this.makeUpData[id].choose_color=this.c_color;
        }
        else{
            this.makeUpData[id].choose_color=this.n_color;
        }
    },
//    这下面三个方法是语音识别的方法
    /*start() {
        jsCallJavaAbility.callAbility("ControllerAbility",100,{}).then(result=>{
            console.log(result)
        })
        console.info("开始")
    },
    stop() {
        jsCallJavaAbility.callAbility("ControllerAbility",101,{}).then(result=>{
            console.log(result)
        })
        jsCallJavaAbility.unSubAbility("ControllerAbility",201).then(result=>{
            if (result.code == 200) {
                console.log("取消订阅成功");
            }
        })
        console.info("关闭订阅")
    },
    sub() {
        jsCallJavaAbility.subAbility("ControllerAbility", 200, (data) => {
            let text = data.data.text

            text && (this.text += text)
            console.info(text)
            if(this.text.indexOf("拍照")>-1){

                this.iskey=1;
                this.text=this.text.slice(0,this.text.length-2)
                this.take_picture()
            }
            if(this.text.indexOf("成熟的发型")>-1){
                this.iskey=2;
                this.text=this.text.slice(0,this.text.length-5)
                this.itemClick(2)
            }
            if(this.text.indexOf("换一个")>-1){
                this.iskey=3;
                this.text=this.text.slice(0,this.text.length-3)
                this.itemClick(1)
            }

        }).then(result => {
            if (result.code == 200) {
                console.log("订阅成功");
            }
        })

    },*/
}